package com.atom.plugin.core.utils

import java.io.File
import java.io.IOException

object ZipUtils {

    @JvmStatic
    fun preventZipSlip(output: File, zipEntryName: String): Boolean {
        try {
            if (zipEntryName.contains("..") && File(output, zipEntryName).canonicalPath.startsWith(
                    output.canonicalPath + File.separator
                )
            ) {
                return true
            }
        } catch (e: IOException) {
            e.printStackTrace()
            return true
        }
        return false
    }
}